<extend name="./app/Tpl/Public/template.html" />
<block name="content_body">
	<div class="pad-lr-10">
	    <div style="padding:10px; overflow:hidden;">
	    	<div class="main_top" style="clear:both;"><h4>温馨提示：</h4>
    			<ul>
    				<li class="green">1.可以同时调整价格和库存</li>
    			</ul>
	    	</div>
	    </div>
	    <form name="form_edit" id="form_edit" action="{:U('doUpdBatch')}" method="post">
	    	<input type="hidden" value="0" name="is_show">
			<div class="table-list">
			    <table width="100%" cellspacing="0">
			        <thead>
			            <tr> 
			            	<th width="80">商品代码</th>               
			                <th width="100">商品名称</th>
			                <th width="80">规格/单位</th>
			                <th width="80">实际价格</th>
			                <th width="80">推荐价格</th>
			                <th width="80">会员价</th>
			                <th width="80">库存</th>
			                <th width="80">库存警告</th>
			            </tr>
			        </thead>
			    	<tbody>
						<volist name="list" id='val'>
				        <tr>
				        	<td align="center">{$val.prod_id}<input type="hidden" value="{$val.prod_id}" name="id[]"></td>
				        	<td align="center">{$val.name}</td>
				        	<td align="center">{$val.spec|m_prod_spec=$val['spec_qty'],$val['spec_unit']}</td>
				        	<td align="center"><input type="text" class="input-text-sml" value="{$val.price_sale}" name="price_real[]"></td>
				        	<td align="center"><input type="text" class="input-text-sml" value="{$val.price_sale}" name="price_sale[]"></td>
				        	<td align="center"><input type="text" class="input-text-sml" value="{$val.price_vip}" name="price_vip[]"></td>
				        	<td align="center"><input type="text" class="input-text-sml" value="{$val.stock_sale}" name="stock_sale[]"></td>
				        	<td align="center"><input type="text" class="input-text-sml" value="{$val.stock_sale_warn}" name="stock_sale_warn[]"></td>
				        </tr>
				        </volist>
			    	</tbody>
			    </table>
	
			    <div class="btn">
			   	 	<input type="button"  name="form_list_btn_ckDel" value="批量更新 + 不上架" onclick="doSubmit(0)"/>
					<input type="button"  name="form_list_btn_ckDel" value="批量更新 + 上架" onclick="doSubmit(1)"/>
					<input type="button"  name="form_list_btn_ckDel" value="全部清空" onclick="document.location.reload()"/>
					<div id="pages">{$page}</div>
			    </div>
			 </div>
	    </form>
	</div>
<script type="text/javascript">

function doSubmit(is_show){
	var formObj = document.forms['form_edit'];
	var elsObj = formObj.elements;
	elsObj['is_show'].value= is_show;
	var codes = elsObj['id[]'];
	var stock_sales = elsObj['stock_sale[]'];
	var price_reals = elsObj['price_real[]'];
	var price_sales = elsObj['price_sale[]'];
	var price_vips = elsObj['price_vip[]'];
	for(var i=0 ; i<codes.length ; i++){
		if(is_show==1 && !isNatNum(stock_sales[i].value)){
			alert(codes[i].value+':上架商品库存不能为空');
			return false;
		}
		if(!isMoney(price_reals[i].value) || !isMoney(price_sales[i].value) || !isMoney(price_vips[i].value)){
			alert(codes[i].value+':商品价格设置不正确');
			return false;
		}
	}
	
	$('#form_edit').submit();
}
$(function(){
	
	$.formValidator.initConfig({
		formID:"form_edit",
		wideWord:false,
		submitOnce:true
	});
		
})
</script>
</block>	